<?php
class Application_Model_Filter_ComplaintsSearch {
    /**
     * 快速搜索
     */
    public $quick;    
     /**
     * 开始时间
     */
    public $starttime;
    /**
     * 结束时间
     */
    public $endtime;
    /**
     *状态
     */
    public $status;    
    /**
     * 是否删除
     */
    public $isDelete;
    
    function getSearchFileds() {
        $where=array(); 
        $and = "";
        if($this->quick != NULL){
            $userItem = Application_Model_User::getByNikeNameStore($this->quick);
            if($userItem){
                $userarrid = "";
                foreach ($userItem as $uservalue) {
                    $userarrid.= $uservalue->id.",";
                }
                $where[$and." userId in "] = "(".$userarrid."0)";
                $and = " or ";
            }
            $where[$and." title like "] = "%".$this->quick."%";
            $and = " and ";
        }
        if ($this->starttime != NULL) {
            $where[$and . ' createTime >= '] = $this->starttime;
            $and = ' and ';
        }
        if ($this->endtime != NULL) {
            $where[$and . ' createTime <= '] = $this->endtime." 23:59:59";
            $and = ' and ';
        }
        if($this->status == 0){
            $where[$and.' (status is null or status = 0) and '] = 1;
            $and = ' and ';
        }else if($this->status == 1){
            $where[$and.' status = '] = 1;
            $and = ' and ';
        }
        if($this->isDelete == 1){
            $where[$and.' isDelete = '] = 1;
            $and = ' and ';
        }else{
            $where[$and . " (isDelete is null or isDelete = 0) and "] = 1;
            $and = ' and ';
        }
        return $where;
    }
    
}

